  
    <div class="user_head_info">
    <div class="user_ava"> 
        <?php if(Yii::app()->user->getState('avatar')) : ?>
        <img src="/images/uploads/userAvatars/<?php echo Yii::app()->user->getState('avatar'); ?>" style="width:30px; height: 30px;"/>
        <?php else : ?>
        <img src="/images/prettyImg/default-avatarl.jpg" width="45px" alt="" />
        <?php endif; ?>
    </div>    
    <span class="profile_username"><?php echo Yii::app()->user->getState('displayName'); ?></span><br/>
   <span class="last_login">Последний раз был   <?php echo Yii::app()->dateFormatter->format("dd MMMM в HH:mm", Yii::app()->user->getState('logDate')); ?></span> 
  
</div>
    
    
    
<?php $this->renderPartial('//partials/userMenu', array('countNewComments'=>$this->countNewComments['count'], 'countNewMessages'=>$this->countNewMessages['count'],'curent'=>'messages')); ?>
<script>var userLogin = '<?php echo Yii::app()->user->getState('login'); ?>';</script>
<script src="/js/messages.js"></script>
<div class="padding4020">
    <div>
    <ul class="unstyled message_menu ">
    <li  class=""><a href="<?php echo Yii::app()->createUrl('user/messages/messages'); ?>">Входящие</a></li>
      <li class="selected"><a class="" href="<?php echo Yii::app()->createUrl('user/messages/outbox'); ?>">Отправленные</a></li>
    <li><a class="" href="<?php echo Yii::app()->createUrl('user/messages/capt'); ?>">Корзина</a></li>
    </ul>
    </div>
    <div class="clearfix"></div>
    <div style="margin-bottom: 20px;height: 20px;margin-top: 15px;">
        <span id="showOrHideForm" class="write_link pull-left">Написать</span>
        <?php if(count($dialogs)) : ?>
            <span class="pull-right mes_numbers"><?php echo count($dialogs); ?> из <?php echo $pagination->getItemCount(); ?> сообщений</span>
        <?php endif; ?>
    </div>
    <div class="clearfix"></div>
    <div class="error" style="background-color: #CCDDFF; display: none; position:absolute; top:8%">
        Рассылка сообщений возможна для 5 пользователей максимум.
    </div>
    
    <div id="formContainer" style="display:none">
        <div class="forum_form_cut"></div>
        <div class="comment_form">
            <div style="width:100%;display: inline-block;"><span class="pull-right close_form" onclick="$('#formContainer').slideUp(600)"></span></div>
        <?php echo CHtml::errorSummary($model, 'Пожалуйста исправьте следующие ошибки:'); ?>

        <?php echo CHtml::beginForm('', 'post', array('id'=>'messageForm')); ?>

            
            
             <div class="pull-left">
                 <label style="color:#898989;fomt-size:12px;" for="adressWrapper">Кому</label>
                  <div id="adressWrapper">
                <span id="adressContainer" style="position:relative; border: 1px solid #c8c7c7; padding-left:562px; padding-bottom:10px; cursor: text; background-color: white;">
                    <textarea id="adressInput" style="width:550px; overflow:hidden; height: 18px; background-color: #ffffff; box-shadow: none; position: absolute; top:0px; left:0px; resize: none; border:none"></textarea>
                </span>   
                    </div>
                 <div class="clearfix"></div>
            
            <div id="autoComplete"></div>
            
          
            <?php echo CHtml::activeHiddenField($model, 'users', array('id'=>'usersTo', 'value'=>'')); ?>   
                 <br/> 
               
                 <?php echo CHtml::activeLabel($model, 'message',array('style'=>'color:#898989;fomt-size:12px;')); ?>
        <?php echo CHtml::activeTextArea($model, 'message', array('class'=>'text_area_comm', 'id'=>'messagearea','style'=>'width:550px;')); ?>
    </div>    
        
    <div class="pull-left" style="margin-left: 23px;margin-top: 20px;">
      
        <div style="color:#898989;font-size:12px;margin-left: 20px;">Через запятую, не более 5<br/> адресатов</div>
           
       
      </div>  
            
        
        
  <div class="clearfix"></div> 
  
  <div style="height:40px;"></div>
            
            
            
            
            
            
                
           
            <br/>

            <?php echo CHtml::button('Отправить', array('class'=>'bt_submit_review', 'id'=>'submitButton')); ?>

        <?php echo CHtml::endForm(); ?> 
    </div>
    </div>
    <div class="message-list">
        
        <?php if(isset($dialogs) && !empty($dialogs)) : ?>
            <?php foreach ($dialogs as $item) : ?>
                <div class="messItem">
                <div class="message_status pull-left">  
                    <?php if($item['user1New'] == Yii::app()->user->getId() || $item['user1New'] == Yii::app()->user->getId()) : ?>
                 <span class="msg_red">&nbsp;</span>
                    <?php else : ?>
                 <span class="msg_new">&nbsp;</span>
                   <?php endif; ?>
                   </div> 
                    <div class="user_inf pull-left">
    <div class="user_ava" style="margin-top: 5px;"> 
        <?php if(!empty($item['avatar'])) : ?>
            <img src="/images/uploads/userAvatars/<?php echo $item['avatar']; ?>" style="width:30px; height: 30px;"/>
        <?php else : ?>
            <img src="/images/prettyImg/default-avatarl.jpg" width="45px" alt="" />
        <?php endif; ?>
    </div>    
    <span style="font-size:12px;"> 
        <?php if(!empty($item['fromId'])) : ?>     
            <a  href="<?php echo Yii::app()->createUrl('user/profile/profile', array('login'=>$item['login'])); ?>"><?php echo $item['displayName']; ?></a>
        <?php else : ?>
            <a  href="<?php echo Yii::app()->createUrl('site/index'); ?>">Партнеркин</a>
        <?php endif; ?>   
    </span><br/>
   <span class="last_login"><?php echo Yii::app()->dateFormatter->format("dd MMMM yyyy в HH:mm", $item['sendDate']); ?></span> 
  
                </div>
                    
                    
                    <div class="pull-left message_text">
                    
                    
                    
                    <?php $text = strip_tags($item['message']); ?>
                    <?php if(mb_strlen($text) > 200) : ?>
                      <?php $message = CPartnerkiHelper::getShortText($item['message'], 200).'...'; ?>
                    <?php else : ?>    
                      <?php $message = $item['message']; ?>  
                    <?php endif; ?>
                                       
                    <?php if($item['user1New'] == Yii::app()->user->getId() || $item['user1New'] == Yii::app()->user->getId()) : ?>
                        <b><a  href="<?php echo Yii::app()->createUrl('user/messages/dialog', array('fromId'=>$item['fromId'], 'toId'=>$item['toId'])); ?>"><?php echo $message; ?></a></b>
                    <?php else : ?>
                        <a href="<?php echo Yii::app()->createUrl('user/messages/dialog', array('fromId'=>$item['fromId'], 'toId'=>$item['toId'])); ?>"><?php echo $message; ?></a>  
                    <?php endif; ?>
                     </div>
                    <?php if(!empty($item['fromId']) && $item['fromId']) : ?>        
                        <div class="messageManagment">
                            <?php echo CHtml::link('Ответить', array('messages/dialog', 'fromId'=>$item['fromId'], 'toId'=>$item['toId']),array('class'=>'write_link')); ?>&nbsp;&nbsp;&nbsp;
                            <?php echo CHtml::link('Удалить переписку', array('messages/delDialog', 'dialogId'=>$item['dialogId']),array('class'=>'write_link')); ?>
                        </div>
                        <div class="messageArea"></div>
                    <?php endif; ?> 
                       
                </div>
           <div class="clearfix"></div>
            <?php endforeach; ?>
        <?php endif; ?>    
    </div>
    
    <div class="pages"><?php $this->widget('CLinkPager', array('pages' => $pagination)); ?> </div>
</div>